Skip to content

Extend predictive low alarm to Trio#680

Open
bjorkert wants to merge 2 commits into
devfrom
trio-predicted-low
Open

Extend predictive low alarm to Trio#680
bjorkert wants to merge 2 commits into
devfrom
trio-predicted-low

Conversation

@bjorkert

@bjorkert bjorkert commented Jun 20, 2026

Copy link
Copy Markdown
Member

The low alarm's predictive look-ahead only handled Loop's single forecast. Trio publishes four separate forecasts (ZT, IOB, COB, UAM), so the predictive series was empty and the early low warning never fired.

This builds the alarm's forward series from the lowest of the four forecasts at each point in time, giving Trio an equivalent predictive-low signal: the alarm fires if any forecast dips to or below the threshold.

Note: the look-ahead was in practice broken for Loop as well. Since the 3.0 alarm rewrite, the BG-limit gate treated the low alarm's belowBG as an activation limit and blocked evaluation until the latest reading was already at or below it, so the early warning could never fire ahead of a low (this worked in 2.x). Conditions can now declare that they check their own threshold; LowBGCondition does, and evaluates the latest reading, persistence, and forecast in one place.

  • AlarmTask: new lowestForecast combiner and alarmPredictionData, which feeds the low condition for both Loop and Trio.
  • AlarmCondition: new checksOwnBGLimits so a condition can own its BG threshold instead of having it enforced as an activation limit.
  • LowBgAlarmEditor: wording now refers to the forecast instead of Loop's prediction, and drops the "not available for Trio" note.
  • Tests for the forecast combining and the low condition across Loop and Trio inputs, including shouldFire-level coverage of the gate.

Also adds a missing import Foundation to SensorAgeConditionTests, which otherwise failed to compile under the current Xcode.

The low alarm's predictive look-ahead only worked with Loop, which
publishes a single forecast. Trio publishes four separate forecasts
(ZT, IOB, COB, UAM), so the predictive series was empty and the
look-ahead never fired.

Build the alarm's forward series from the lowest of the four forecasts
at each point in time, so the alarm fires if any forecast dips to or
below the threshold. Update the low alarm editor wording to refer to
the forecast rather than to Loop's prediction.

Add tests for the forecast combining and the low condition for both
Loop and Trio inputs.
bjorkert added a commit that referenced this pull request Jul 8, 2026
# Conflicts:
#	Tests/AlarmConditions/Helpers.swift
… can fire

The BG-limit gate treated the low alarm's belowBG as an activation
limit, blocking evaluation until the latest reading was already at or
below it, which made the predictive look-ahead unreachable. Conditions
can now declare that they check their own threshold; LowBGCondition
does, evaluating the latest reading, persistence, and forecast in one
place.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant